<template>

        <div class="line-head">
          <el-button type="primary"  @click="sendToParent" >配置保存</el-button>
        </div>
        <div class="paramode">策略参数配置</div>
        <div class="line-head">
            <span>策略模式选择:</span>
            <el-select v-model="policCfg.remote_adj.policy_mode"
              @change="Show"
              placeholder="请选择" class="elselect">
                <el-option
                  v-for="item in PolicySel"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
              <span>需量pid:</span>
              <el-select v-model="policCfg.remote_adj.demand_mode"
                @change="Show"
                placeholder="请选择" class="elswitchselect">
                  <el-option
                    v-for="item in SwitchSel"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
                <span></span>
                <span>逆流pid:</span>
                <el-select v-model="policCfg.remote_adj.anti_reflux_mode"
                  @change="Show"
                  placeholder="请选择" class="elswitchselect">
                    <el-option
                      v-for="item in SwitchSel"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                  <span></span>

                  <span>负荷跟踪pid:</span>
                  <el-select v-model="policCfg.remote_adj.load_track_mode"
                    @change="Show"
                    placeholder="请选择" class="elswitchselect">
                      <el-option
                        v-for="item in SwitchSel"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                    <span></span>
            <span>环境温度过高:</span>
            <el-input  class="elinput"
            placeholder="请输入内容"
            type="number"
            v-model.number="policCfg.remote_adj.upper_limit_env_temp">
          </el-input>
          <span>℃</span>
        </div>
        <div class="line-head">
            <span>最大放电功率:</span>
              <el-input  class="elinput"
              placeholder="请输入内容"
              type="number"
              v-model.number="policCfg.remote_adj.max_dis_charge_power">
            </el-input>
            <span>kw</span>
            <span>最大充电功率:</span>
              <el-input  class="elinput"
              placeholder="请输入内容"
              type="number"
              v-model.number="policCfg.remote_adj.max_charge_power">
            </el-input>
            <span>kw</span>
            <span>功率分配模式:</span>
            <el-select v-model="policCfg.remote_adj.power_distribution_mode"
            @change="Show"
            placeholder="请选择" class="elselect">
              <el-option
                v-for="item in powerDistri"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
            <span>充放电方向:</span>
            <el-select v-model="policCfg.remote_adj.power_para.charge_discharge_mode"
            @change="Show"
            placeholder="请选择" class="elselect">
              <el-option
                v-for="item in powerChaDis"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>

        </div>
        <div class="line-head">
            <el-collapse accordion>
              <el-collapse-item title="SOC参数配置->">
                <div> <span>soc上限:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.soc_para.soc_max">
                      </el-input>
                      <span>%</span>
                      <span>soc下限:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.soc_para.soc_min">
                      </el-input>
                      <span>%</span>
                      <span>soc离网下限:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.soc_para.dis_conn_grid_soc_min">
                      </el-input>
                      <span>%</span>
                  
                  </div>
              </el-collapse-item>
          </el-collapse>  
      </div>
        <div class="line-head">
              <el-collapse accordion>
                <el-collapse-item title="增容参数配置->">
                  <div> <span>负载充电下限:</span>
                        <el-input  class="elinput"
                        placeholder="请输入内容"
                        v-model="policCfg.remote_adj.increase_capa_para.load_charge_low">
                        </el-input>
                        <span>kw</span>
                        <span>负载放电下限:</span>
                        <el-input  class="elinput"
                        placeholder="请输入内容"
                        v-model="policCfg.remote_adj.increase_capa_para.load_discharge_low">
                        </el-input>
                        <span>kw</span>
                        <span>放电回差:</span>
                        <el-input  class="elinput"
                        placeholder="请输入内容"
                        v-model="policCfg.remote_adj.increase_capa_para.load_discharge_low">
                        </el-input>
                        <span>kw</span>
                        <span>放电回差补偿:</span>
                        <el-input  class="elinput"
                        placeholder="请输入内容"
                        v-model="policCfg.remote_adj.increase_capa_para.load_discharge_low">
                        </el-input>
                        <span>kw</span>
                    </div>
                </el-collapse-item>
            </el-collapse>  
        </div>
        <div class="line-head">
            <el-collapse accordion>
              <el-collapse-item title="PID参数配置->" name="2">
                  <div><span>P参数:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.pid_para.p">
                      </el-input>
                      <span></span>
                      <span>I参数:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.pid_para.i">
                      </el-input>
                      <span></span>
                      <span>D参数:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.pid_para.d">
                      </el-input>
                  </div>
                </el-collapse-item>
          </el-collapse>  
      </div>
      <div class="line-head">
        <el-collapse accordion>
          <el-collapse-item title="单体参数配置->" name="2">
              <div><span>电梯电压过低:</span>
                  <el-input  class="elinput"
                  placeholder="请输入内容"
                  type="number"
                  v-model.number="policCfg.remote_adj.cell_para.vol_lower">
                  </el-input>
                  <span>v</span>
                  <span>单体电压过高:</span>
                  <el-input  class="elinput"
                  placeholder="请输入内容"
                  type="number"
                  v-model.number="policCfg.remote_adj.cell_para.vol_hight">
                  </el-input>
                  <span>v</span>
                  <span>单体温度过高:</span>
                  <el-input  class="elinput"
                  placeholder="请输入内容"
                  type="number"
                  v-model.number="policCfg.remote_adj.cell_para.temp_hight">
                  </el-input>
              </div>
            </el-collapse-item>
        </el-collapse>  
        </div>
 

       <div class="line-head">
            <el-collapse accordion>
              <el-collapse-item title="时间线参数->" name="2">
                  <div><span>策略优先级:</span>
                    <el-select v-model="policCfg.remote_adj.priority"
                    @change="Show"
                    placeholder="请选择" class="elselect">
                      <el-option
                        v-for="item in PriSel"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                      <span></span>
                      <span>开始日期:</span>
                      <el-date-picker
                      v-model="policCfg.remote_adj.data.start_date"
                      type="date"
                      placeholder="选择日期"
                      format="YYYY-MM-DD"
                      value-format="YYYY-MM-DD"
                    </el-date-picker>
                    <span></span>
                    <span>结束日期:</span>
                    <el-date-picker
                      v-model="policCfg.remote_adj.data.end_date"
                      type="date"
                      format="YYYY-MM-DD"
                      value-format="YYYY-MM-DD"
                      placeholder="选择日期">
                    </el-date-picker>
                      <span></span>
                      <span>星期设置:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      v-model="policCfg.remote_adj.data.week_day">
                      </el-input>
                      <span></span>
                  </div>
                  <div class="time-line">时间线配置表：</div>
                  <div class="timeline-head" v-for="(item,id) in policCfg.remote_adj.time_line">
                  <!-- <span v-for="(item,index) in policCfg.remote_adj.time_line">{{ index }}</span> -->
                    <span>开始时间:</span>
                    <el-time-picker
                        v-model="policCfg.remote_adj.time_line[id].start_time"
                        value-format="HH:mm:ss"
                        :picker-options="{
                        selectableRange: '18:30:00 - 20:30:00'
                        }"
                        placeholder="任意时间点">
                    </el-time-picker>
                    <span></span>
                    <span>结束时间:</span>
                    <el-time-picker
                        v-model="policCfg.remote_adj.time_line[id].stop_time"
                        value-format="HH:mm:ss"
                        :picker-options="{
                        selectableRange: '18:30:00 - 20:30:00'
                        }"
                        placeholder="任意时间点">
                    </el-time-picker>
                    <span></span>
                    <span>功率:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.time_line[id].power">
                      </el-input>
                      <span>kw</span>
                      <span>百分比:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.time_line[id].ratio">
                      </el-input>
                      <span>%</span>
                      <span>负载差值功率:</span>
                      <el-input  class="elinput"
                      placeholder="请输入内容"
                      type="number"
                      v-model.number="policCfg.remote_adj.time_line[id].track_power">
                      </el-input>
                      <span>kw</span>
                      <span>模式选择:</span>
                      <el-select v-model="policCfg.remote_adj.time_line[id].mode"
                        @change="Show"
                        placeholder="请选择" class="elselecttl">
                        <el-option
                            v-for="item in timelineModeSel"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                        </el-option>
                        </el-select>
                        <span></span>
                  </div>
                </el-collapse-item>
            </el-collapse>  
            </div>



        <el-divider ></el-divider>
        <div>
            <div class="paramode">策略控制参数配置</div>
            <div class="line-head">
              <span>开关机:</span>
                  <el-select v-model="policCfg.remote_ctrl.station_open_ctrl"
                    @change="Show"
                    placeholder="请选择" class="elswitchselect">
                      <el-option
                        v-for="item in SwitchSel"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                    <span></span>
                    <span>并离网:</span>
                    <el-select v-model="policCfg.remote_ctrl.station_grid_conn_ctrl"
                      @change="Show"
                      placeholder="请选择" class="elswitchselect">
                        <el-option
                          v-for="item in SwitchSel"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                      <span></span>

                      <span>防逆流:</span>
                      <el-select v-model="policCfg.remote_ctrl.anti_reflux_ctrl"
                        @change="Show"
                        placeholder="请选择" class="elswitchselect">
                          <el-option
                            v-for="item in SwitchSel"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                        <span></span>

                        <span>容量控制:</span>
                        <el-select v-model="policCfg.remote_ctrl.grid_capa_ctrl"
                          @change="Show"
                          placeholder="请选择" class="elswitchselect">
                            <el-option
                              v-for="item in SwitchSel"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                          <span></span>
            </div>
            
            <div class="line-head">
              <span>动态需量:</span>
              <el-select v-model="policCfg.remote_ctrl.grid_demand_ctrl"
                @change="Show"
                placeholder="请选择" class="elswitchselect">
                  <el-option
                    v-for="item in SwitchSel"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
                <span></span>

                <span>环境温度过热保护:</span>
                <el-select v-model="policCfg.remote_ctrl.environ_temper_protect"
                  @change="Show"
                  placeholder="请选择" class="elswitchselect">
                    <el-option
                      v-for="item in SwitchSel"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                  <span></span>

                  <span>SOC充放电控制:</span>
                  <el-select v-model="policCfg.remote_ctrl.dod_protect"
                    @change="Show"
                    placeholder="请选择" class="elswitchselect">
                      <el-option
                        v-for="item in SwitchSel"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                    <span></span>

                    <span>离网soc放电保护:</span>
                    <el-select v-model="policCfg.remote_ctrl.soc_grid_disconn_protect"
                      @change="Show"
                      placeholder="请选择" class="elswitchselect">
                        <el-option
                          v-for="item in SwitchSel"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                      <span></span>
            </div>

            <div class="line-head"> 

              <span>单体电芯高压保护:</span>
              <el-select v-model="policCfg.remote_ctrl.cell_max_vol_protect"
                @change="Show"
                placeholder="请选择" class="elswitchselect">
                  <el-option
                    v-for="item in SwitchSel"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
                <span></span>

                <span>单体电芯低压保护:</span>
                <el-select v-model="policCfg.remote_ctrl.cell_minx_vol_protect"
                  @change="Show"
                  placeholder="请选择" class="elswitchselect">
                    <el-option
                      v-for="item in SwitchSel"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                  <span></span>

                  <span>单体电芯低压保护:</span>
                  <el-select v-model="policCfg.remote_ctrl.pack_max_temper_protect"
                    @change="Show"
                    placeholder="请选择" class="elswitchselect">
                      <el-option
                        v-for="item in SwitchSel"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                    <span></span>

                    <span>一次调频:</span>
                    <el-select v-model="policCfg.remote_ctrl.primary_freq_module_ctrl"
                      @change="Show"
                      placeholder="请选择" class="elswitchselect">
                        <el-option
                          v-for="item in SwitchSel"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                      <span></span>

            </div>
            <div class="line-head">
              
              <span>电能质量:</span>
              <el-select v-model="policCfg.remote_ctrl.electricity_quality_ctrl"
                @change="Show"
                placeholder="请选择" class="elswitchselect">
                  <el-option
                    v-for="item in SwitchSel"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
                <span></span>
          
                <span>BMS上高压:</span>
                <el-select v-model="policCfg.remote_ctrl.bms_up_vol_ctrl"
                  @change="Show"
                  placeholder="请选择" class="elswitchselect">
                    <el-option
                      v-for="item in SwitchSel"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                  <span></span>
            </div>
        </div>
</template>



<script setup name="polic">
import{defineProps,defineEmits,toRef} from 'vue'
const emit = defineEmits(['child-message'])
const policCfg = toRef({
    remote_adj:{
        run_mode:1,
        policy_mode:0,
        proxy_mode:0,//0-sche，1-modbus 2-iec104 3-mudbus-auto  4-iec104-auto
        demand_mode:0,//0-直接计算，1-pid模式
        anti_reflux_mode: 0, //防逆流   0-直接计算，1-pid模式
        load_track_mode:0,//负荷跟踪，0-直接计算，1-pid计算模式
        max_dis_charge_power:100,//最大放电功率
        max_charge_power:100,//最大放电功率
        station_capacity:200,//变压器容量
        increase_capa_para:{
            load_charge_low:0,//负载充电下限
            load_discharge_low:0,//负载放电下限
            load_discharge_ret_diff:0,//放电回差
            ret_diff_pay:0//放电回差区间放电功率
        },
        pid_para:{
            p:10,
            i:20,
            d:30,
        },
        power_para:{
            charge_discharge_mode:1,
            action_power:0,//有功功率
            ReactivePower:0,//无功功率
        },
        air_para:{
            refrigeration_temp:30,//制冷温度
            cooling_return_diff:3,//制冷回差
            heating_temp:8,//制热温度
            heat_return_diff:3,//制热回差
        },
        upper_limit_env_temp:50,//环境温度过高
        soc_para:{
            soc_max:90,
            soc_min:5,
            dis_conn_grid_soc_min: 20,//离网放电soc设置
        },
        cell_para:{
            vol_lower:2.0,//
            vol_hight:3.5,//
            temp_hight:60
        },
        gener_para:{
            vol_hight:400,
            vol_lower:280,
            freq_hight:52,
            FreqLower:49,
            ch_disch_step:10,
        },
        reactive_para:{
            capacitive_reactive:30,//容性无功上限
            sensory_reactive:30,//感性无功上限，
        },
        power_distribution_mode:0,//0-平均分配，基于soc分配，基于bms能力，soc，bms结合
        trans_para:{
            capacity:1000,//变压器容量
            ratio:1,//变比
            demond:10,//需量初始值
        },
        data:{
            start_date:"",
            end_date:"",
            week_day:"",
        },
        priority:0,
        time_line:[
            {
            mode:0,
            start_time:"",
            stop_time:"",
            power:0,
            ratio:0,
            track_power:0,
        },
        {
            mode:0,
            start_time:"",
            stop_time:"",
            power:0,
            ratio:0,
            track_power:0,
        },
        {
            mode:0,
            start_time:"",
            stop_time:"",
            power:0,
            ratio:0,
            track_power:0,
        },{
            mode:0,
            start_time:"",
            stop_time:"",
            power:0,
            ratio:0,
            track_power:0,
        },
        {
            mode:0,
            start_time:"",
            stop_time:"",
            power:0,
            ratio:0,
            track_power:0,
        },{
            mode:0,
            start_time:"",
            stop_time:"",
            power:0,
            ratio:0,
            track_power:0,
        }
        ]
    },
    remote_ctrl:{
        station_open_ctrl:0,
        station_grid_conn_ctrl:0,
        anti_reflux_ctrl:0,
        grid_capa_ctrl:0,
        grid_demand_ctrl:0,
        environ_temper_protect:0,
        dod_protect:1,
        soc_grid_disconn_protect:0,
        cell_max_vol_protect:0,
        cell_minx_vol_protect:0,
        pack_max_temper_protect:0,
        primary_freq_module_ctrl:0,
        electricity_quality_ctrl:0,
        bms_up_vol_ctrl:0,
    }
})

let TimeLine={
    mode:0,
    start_time:"",
    stop_time:"",
    power:0,
    ratio:0,
    track_power:0,
}



let number = defineProps(["number"])
let timelineModeSel =[
        {
                value: 0,
                label: '停机'  
        },
        {
                value: 1,
                label: '充电'  
        },
        {
                value: 2,
                label: '放电'  
        },
        {
                value: 3,
                label: '零功率'  
        },
        {
                value: 4,
                label: '放电负荷跟踪'  
        },
        {
                value: 5,
                label: '充电光伏跟踪'  
        },
        {
                value: 5,
                label: '放电负荷跟踪差值'  
        }
    ]
let PriSel=[
        {
                value: 1,
                label: '1'  
        },
        {
                value: 2,
                label: '2'  
        },
        {
                value: 3,
                label: '3'  
        },
        {
                value: 4,
                label: '4'  
        },
        {
                value: 5,
                label: '5'  
        },
        {
                value: 6,
                label: '6'  
        },
]
let powerChaDis = [
            {
                value: 1,
                label: '正充'  
            },
            {
                value: -1,
                label: '负充'  
            },
]

let SwitchSel= [
  {
          value: 0,
          label: '关闭'
  },
  {
          value: 1,
          label: '开启'
  },
]

let PolicySel= [{
          value: 0,
          label: '无策略'
        }, {
          value: 1,
          label: '削峰填谷'
        }, {
          value: 2,
          label: '变压器增容'
        }, {
          value: 3,
          label: '光储光伏不可控'
        }, {
          value: 4,
          label: '光储光伏可控'
        }, {
          value: 5,
          label: '柴储'
        }, {
          value: 6,
          label: '光储并离网'
        },{
          value: 7,
          label: '光储柴并离网'
        }
    ];
let powerDistri=[
        {
          value: 0,
          label: '平均分配'
        },
        {
          value: 1,
          label: '基于soc'
        },
        {
          value: 2,
          label: '基于bms能量'
        },
        {
          value: 3,
          label: 'soc,bms结合'
        }
]
function Show(){
    console.log(policCfg.value.remote_adj.policy_mode);
}

function sendToParent(){
  emit('child-message', policCfg.value,number)
}
</script>

<style>
.paramode{
    text-align: center;
    margin-bottom: 30px;
    font-size: 30px;
    font-weight: 900;
}
.elselect{
    width: 200px;
    margin-right: 30px;
}
.line-head{
    margin-top: 20px;
}
.elinput{
    width:200px;
}
.line-head span{
    margin-right: 20px;  
    font-weight: 600; 
    
}
.head-collapse{
     font-size: x-large; 
}
.time-line{
    margin-top: 20px;
    text-align: center;
    margin-bottom: 30px;
    font-size: 20px;
    font-weight: 900;
}
.timeline-head{
    margin-top: 10px;
    margin-bottom: 10px;
}
.timeline-head .elinput{
    width:80px
}
.elselecttl{
    width: 100px;
}
.elswitchselect{
  width: 90px;
}
</style>